using GalaSoft.MvvmLight;
using System.IO;
using GoogleAPIOnWindowsPhone.Resources;
using GoogleAPIOnWindowsPhone.Model;
using Newtonsoft.Json;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System;
using System.Collections.ObjectModel;

namespace GoogleAPIOnWindowsPhone.ViewModel
{
    /// <summary>
    /// This class contains properties that the main View can data bind to.
    /// <para>
    /// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
    /// </para>
    /// <para>
    /// You can also use Blend to data bind with the tool's support.
    /// </para>
    /// <para>
    /// See http://www.galasoft.ch/mvvm
    /// </para>
    /// </summary>
    public class MainViewModel : ViewModelBase 
    {
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public ObservableCollection<ATMBoothList> PlacesList { get; set; }
        public ObservableCollection<ATMBoothList> PlacesList2 { get; set; }
        public ObservableCollection<LocalityClass> Area { get; set; }
        public List<TypeOFList> list { get; set; }
        public List<GeoCollection> geo { get; set; }
        public MainViewModel()
        {
            ////if (IsInDesignMode)
            ////{
            ////    // Code runs in Blend --> create design time data.
            ////}
            ////else
            ////{
            ////    // Code runs "for real"
            ////}
            System.IO.StreamReader myFile = new System.IO.StreamReader(@"Resources\NewDataSource.txt");
            string myString = myFile.ReadToEnd();
            PlacesList = (JsonConvert.DeserializeObject<ObservableCollection<ATMBoothList>>(myString));


            System.IO.StreamReader myFile2 = new System.IO.StreamReader(@"Resources\Location.txt");
            string myString2 = myFile2.ReadToEnd();
            Area = (JsonConvert.DeserializeObject<ObservableCollection<LocalityClass>>(myString2));



            list = new List<TypeOFList>();
            list.Add(new TypeOFList() { Types = "atm" });
            list.Add(new TypeOFList() { Types = "hospital" });
            list.Add(new TypeOFList() { Types = "bank" });

            
            geo = new List<GeoCollection>();
            //foreach (var item in PlacesList)
            //{
            //    location = item.Latitude.ToString() + "," + item.Longitude.ToString();
            //    geo.Geo.Add(location);
            //}
            geo.Add(new GeoCollection() { Geo = "23.87185,90.400918" });
            geo.Add(new GeoCollection() { Geo = "23.873884,90.400229" });
            geo.Add(new GeoCollection() { Geo = "23.874429,90.39986" });
            geo.Add(new GeoCollection() { Geo = "23.87676,90.400806" });
        }
    }
}